"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/10/23 14:16
@Description :   循环结构中的两个关键词
break     结束循环
continue  结束本次循环继续下次循环
"""
# 1-50之间数字的和
sum = 0
for i in range(1, 51):
    sum += i
    #  sum >= 500  停止循环
    if sum >= 500:
        print(f'sum={sum}, i={i}')
        break
print(f'sum = {sum}')

print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')

for i in range(1, 10):
    #  判定i 如果是偶数则将程序的执行停止
    if i % 2 == 0:
        continue  # 结束本次循环继续下次循环
    print(i)

print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')

for i in range(1, 10):
    print(f'i={i}')
    if i == 5:
        break
else:
    print('循环正常结束了...')

count = 0
while count < 5:
    print('hello')
    count += 1
    if count == 3:
        break
else:
    print('循环正常结束了...')
